package com.fivefu.core.data.controller;

import com.fivefu.base.common.utils.str.StrUtils;
import com.fivefu.base.web.controller.BaseController;
import com.fivefu.base.web.vo.ResultInfo;
import com.fivefu.core.data.services.DbFfskyeyeDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 设备 前端控制器
 * </p>
 *
 * @author 
 * @since 2022-09-01 19:22:07
 */
@Api(tags = "设备信息汇总")
@RestController
@RequestMapping("/ffskyeyeDevice")
public class DbFfskyeyeDeviceController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(DbFfskyeyeDeviceController.class);

    @Autowired
    private DbFfskyeyeDeviceService dbFfskyeyeDeviceService;

    @ApiOperation(value = "设备信息汇总入库",httpMethod = "GET",response = ResultInfo.class,notes = "设备信息汇总入库")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "设备平台：海康，大华",paramType = "query",required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId",value = "用户编号",paramType = "query",required = true, dataType = "String")
    })
    @RequestMapping(path = "/deviceCollect",method = RequestMethod.GET)
    public ResultInfo deviceCollect(String type,String userId) {
        try {
            if (StrUtils.isNull(type)) {
                return ResultInfo.renderError("设备平台不能为空");
            }
            if (StrUtils.isNull(userId)) {
                return ResultInfo.renderError("用户编号不能位空");
            }
            dbFfskyeyeDeviceService.deviceCollect(type,userId);
            return ResultInfo.renderSuccess("设备信息汇总入库成功");
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
        }
        return  ResultInfo.renderError("设备信息汇总入库失败");
    }
}
